/***************************************************************************
 * File name: EPubBufferImp.h
 * Original author: caizhifei2003@163.com
 * Date: 2013.03.03
 ***************************************************************************/
#ifndef _EPUB_BUFFER_IMP_H_
#define _EPUB_BUFFER_IMP_H_

#include "IEPubBuffer.h"
#include "EPubAllocator.h"

class EPubBufferImp : public IEPubBuffer
{
public:

	EPubBufferImp();
	EPubBufferImp(EPUB_Size size);
	EPubBufferImp(const EPUB_Byte *buffer, EPUB_Size size);
	EPubBufferImp(const IEPubBuffer &other);
	~EPubBufferImp();

	virtual const EPUB_Byte *GetBuffer() const { return m_Buffer; }
	virtual EPUB_Size GetBufferSize() const { return m_BufferSize; }
	virtual EPUB_Byte *UseBuffer() { return m_Buffer; }

	virtual void SetBufferSize(EPUB_Size size);
	virtual void SetBuffer(const EPUB_Byte *buffer, EPUB_Size size);
	virtual void SetBuffer(const IEPubBuffer &other);

	virtual void Clear();

	virtual IEPubBuffer &operator =(const IEPubBuffer &other);

private:
	EPUB_Byte *						m_Buffer;
	EPUB_Size						m_BufferSize;
	EPubAllocator<EPUB_Byte>		m_Allocator;
};

#endif // _EPUB_BUFFER_IMP_H_